﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NeuralNetworks.ActivationFunctions;
using System.Collections;
using NeuralNetworks.Neurons;

namespace NeuralNetworks.Layers
{
    public class ActivationLayer : Layer
    {
        private IActivationFunction actvFunction;
        
        internal IActivationFunction ActvFunction
        {
            get { return actvFunction; }
            set { 
                actvFunction = value;
                foreach (ActivationNeuron n in Neurons) {
                    n.ActivationFunction = actvFunction;
                }
            }
        }

        public ActivationLayer(int nneurons, IActivationFunction f, string name) :
            base(nneurons, name)
        {
            if(f == null){ throw (new NeuralNetworksException()); };
            for (int i = 0; i < nneurons; i++) { AddNeuron(new ActivationNeuron(f)); }
            this.actvFunction = f;
        }

        public void AddNeuron(ActivationNeuron neuron)
        {
            if (neuron == null) { throw (new NeuralNetworksException()); };
            Neurons.Add(neuron);
        }

        public new ActivationNeuron this[int index]
        {
            get { return (ActivationNeuron) Neurons[index]; }
        }
    }
}
